package tree;

/**
 *      5
 *    3   6
 *   2  4
 * 二叉树转链表
 * @author le
 */
public class TreeToList
{
    public static void main(String[] args)
    {
        TreeNode root = new TreeNode(5,new TreeNode(3,new TreeNode(2),new TreeNode(4)),new TreeNode(6));

        System.out.println("中序：");
        mid(root);
        System.out.println("先序遍历");
        pre(root);
    }

    public static void mid(TreeNode root){
        if (root == null){
            return;
        }
        mid(root.left);
        System.out.println(root.val);
        mid(root.right);
    }

    public static void pre(TreeNode root){
        if (root == null){
            return;
        }
        System.out.println(root.val);
        mid(root.left);
        mid(root.right);
    }

}

